package org.thread.test05.tx.demo04;

/**
 * notify 与 notifyAll 方法的使用
 *
 * @author ZQX
 * @date 2025-03-13
 */
public class MainTest extends Object {

    /**
     * 静态方法只能访问静态成员
     *
     * @param args
     */
    public static void main(String[] args) throws InterruptedException {
        MyThread t1 = new MyThread();
        MyThread t2 = new MyThread();
        MyThread t3 = new MyThread();

        t1.start();
        t2.start();
        t3.start();

        // 主线程睡眠5秒后，唤醒子线程
        Thread.sleep(5000);

       synchronized (MyThread.LOCK) {
           // 唤醒子线程
           // MyThread.LOCK.notify();
           MyThread.LOCK.notifyAll();
       }
    }
}
